﻿CREATE PROCEDURE Sync.SP_UsersRoles_SelectChanges
@LastRowVersion rowversion,
@FilterdColumn UNIQUEIDENTIFIER
AS 
BEGIN 
	SELECT 
        t.[RoleID],t.[UserID],
		
		t.IsDeleted,
		t.LastUpdatedDate
	FROM [dbo].[UsersRoles] g RIGHT JOIN Sync.UsersRoles_Tracking t  ON t.RoleID = g.RoleID AND t.UserID = g.UserID 
	join [UsersCommittees] comms on g.UserID = comms.UserID
	WHERE (@LastRowVersion IS NULL OR t.Version > @LastRowVersion)
	and (@FilterdColumn IS NULL) OR (@FilterdColumn = comms.CommitteeID)
    END














